


import {
  get,
  post,
  put,
} from "./base_service"


/**
 * 佳宝签到相关接口
 *
 * allen  2023-12-19
 */

/**
 * 
 * 获取签到配置
 *
 * }
 */
const signConfig = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/user/sign/config").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
/**
* 
* 用户签到一次
*
* }
*/
const personSign = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/user/sign/integral").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
* 
* 今日记录签到信息
*
* }
*/
const signToday = () => {
  return new Promise((resolve, reject) => {
    get("/api/front/user/sign/get").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 
 * 获取用户签到列表
 *
 * }
 */
const personSignList = (page, limit = 10) => {
  return new Promise((resolve, reject) => {
    get("/api/front/user/sign/list?page=" + page + "&limit=" + limit).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 
 * 获取签到用户信息
 *
 * }
 */
const signPersonInfo = (data) => {
  return new Promise((resolve, reject) => {
    post("/api/front/user/sign/user", data).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 
 * 获取用户年月签到列表
 *
 * }
 */
const personSignMonthList = (page, limit = 10) => {
  return new Promise((resolve, reject) => {
    get("/api/front/user/sign/month?page=" + page + "&limit=" + limit).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.message)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}


module.exports = {
  signConfig, // 获取签到配置
  personSign, // 用户签到
  personSignList,//用户签到列表
  signPersonInfo,//签到用户信息
  signToday,//今日签到记录
  personSignMonthList,//用户年月签到记录
}

